<?php
require 'include.php';
#$file = "vbcll.rss";
#if(file_exists($file)) unlink($file);
#if (!($fp = fopen($file, 'w')))
#   return;

$q = "SELECT infos.titre, datetime,concat(prenom,' ',nom) as auteur, infos.id as id ,corps FROM membres,infos where infos.membre_id = membres.id and  infos.valide = 1 ORDER BY DATETIME DESC limit 10;";
$r = ExecRequete($q);
$nb_msg = mysql_num_rows($r);

header("Content-Type: text/xml");

$xml = '<'.'?xml version="1.0" encoding="ISO-8859-1"?'.'><rss version="2.0"><channel>';

$xml .='<title>VBCLL infos</title>';
$xml .='<link>http://www.vbcll.ch</link>';
$xml .='<description>Les dernières infos</description>';
$xml .='<managingEditor></managingEditor>';
$xml .='<language>fr</language>';
$xml .='<generator>PHP</generator>';
$xml .='<copyright>VBCLL</copyright>';
$xml .='<webMaster>Robin Liechti</webMaster>';

while ($msg_data = mysql_fetch_array($r))
{
$id = $msg_data['id'];
$corps = prepare_info($msg_data['corps']);
#$corps = preg_replace("/<img.*>/","",$msg_data['corps']);
#$corps = htmlentities($corps,ENT_QUOTES,'ISO-8859-1');
$titre = $msg_data['titre'];
$news = stripslashes(trim($corps));
$news = str_replace("<BR>",'<BR/>',$news);
$news = str_replace("&",'&amp;',$news);
$news = str_replace("<","&lt;",$news);
$news = str_replace(">","&gt;",$news);

$xml .='<item>';
$xml .='<author>'.$msg_data['auteur'].'</author>';
$xml .='<title>'.$titre.'</title>';
$xml .='<link>http://www.vbcll.ch/infos.php?id='.$id.'</link>';
$xml .='<pubDate>'.$msg_data['datetime'].' GMT</pubDate>';
$xml .='<guid>http://www.vbcll.ch/infos.php?no='.$id.'</guid>';
$xml .='<comments>http://www.vbcll.ch/infos.php?no='.$id.'</comments>';
$xml .='<description>';

$xml .= $news; 

$xml .='</description></item>\n';
}

mysql_close();

$xml .='</channel></rss>';

#if(fwrite($fp,$xml)===FALSE){echo "Ecriture impossible";}
#fclose($fp);
echo $xml;

?>
